package cate.game.play.buff.h;

import cate.common.util.XT;
import cate.game.play.buff.BuffHandler;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.proce.action.ctx.SkillActionCtx;

import java.util.List;

/**
 * 提升25%闪避，持续2回合或触发2次闪避后消失 成功闪避后可恢复最大生命值的7%
 */
public class 一闪BH extends BuffHandler {

	private int 闪避次数;

	private List<Integer> 闪避buff;

	//闪避次数=2&闪避buff=？？
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		闪避次数 = args.getInt("闪避次数", 0);
		闪避buff = args.getIntList("闪避buff" );
	}

	@Override
	public void parseExt(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		闪避buff = XT.merge(闪避buff, args.getIntList("闪避buff"));
	}

	private int missNum;

	@Override
	public void onMissAsTarget(SkillActionCtx action) {
		missNum++;
		if(XT.isNotBlank(闪避buff)){
			for (Integer addBuff : 闪避buff) {
				this.buff.owner.buff.tryAddByTid(action, addBuff);
			}
		}
		if (missNum >= 闪避次数) {
			this.buff.markInvalid(action);
		}
	}
}
